---
title: "Replication Script for Neighboring Identities and Political Attacks"
author: "Basco et al."
date: "07/17/2025"
output:
  html_document:
    theme: readable
    toc: yes
  pdf_document:
    keep_tex: yes
    toc: yes
editor_options:
  chunk_output_type: console
---

<style type="text/css">

body, td {
   font-size: 14px;
}
code.r{
  font-size: 12px;
}
pre {
  font-size: 12px
}
</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F, warning = F, message = F)
```


```{r}
library(tidyverse)
library(car)
library(survey)
library(ggplot2)
library(psych)
library(scales)
library(srvyr)
library(MASS)
library(texreg)
library(poliscidata)
library(xtable)
library(descr) 
library(haven)
library(sjlabelled)
library(ggpubr)
library(devtools)
library(stargazer)
library(jtools) 
library(kableExtra)
```


```{r Data setup, include=FALSE}
# Read in Data #

latino_data<-read_csv("Latino_data.csv")
asian_data<-read_csv("Asian_data.csv")

#Factor and label treatment variable 
latino_data$treatment<- factor(latino_data$treatment, labels = c("Econ", "Latino", "Immigrant"))

#Factor and label treatment variable 
asian_data$treatment<- factor(asian_data$treatment, labels = c("Econ", "Asian", "Immigrant"))


```


#Table 3: Latino Sample Balance Table
```{r Balance Table Latino, include=FALSE}

# 1. Create a new factor for the balance table only
latino_data$treatment_balance_table <- factor(
  latino_data$treatment,
  labels = c("Control", "Ethnicity", "Immigrant")
)

# 2. Specify your variables and their display labels
vars       <- c("age", "income", "education", "female", "native_born")
var_labels <- c("Age", "Income", "Education", "Female", "Native Born")

# 3. Aggregate means by the new treatment_balance_table
agg <- aggregate(
  latino_data[, vars],
  by = list(Treatment = latino_data$treatment_balance_table),
  FUN = function(x) mean(x, na.rm = TRUE)
)
colnames(agg)[1] <- "Treatment"

# 4. Transpose so each variable is a row, treatments are columns
mean_mat <- t(as.matrix(agg[ , -1]))
colnames(mean_mat) <- as.character(agg$Treatment)
rownames(mean_mat) <- vars

mean_df <- data.frame(
  Variable = var_labels,
  round(as.data.frame(mean_mat, stringsAsFactors = FALSE), 2),
  stringsAsFactors = FALSE,
  row.names = NULL
)

# 5. Build the final “N” row so its columns exactly match mean_df
counts   <- table(latino_data$treatment_balance_table)
count_df <- as.data.frame(
  t(as.numeric(counts)),
  stringsAsFactors = FALSE
)
colnames(count_df) <- names(counts)
count_df$Variable <- "N"

# reorder count_df to have the same columns (and order) as mean_df
count_df <- count_df[ , colnames(mean_df)]

# 6. Combine means + N without error
balance_table <- rbind(mean_df, count_df)

# 7. Print a nice HTML table in R/RMarkdown
balance_table %>%
  kable(
    format    = "html",
    digits    = 2,
    col.names = colnames(balance_table),
    caption   = "Balance Test: Means by Treatment"
  ) %>%
  kable_styling(
    full_width        = FALSE,
    bootstrap_options = c("striped", "hover")
  )

# 8. Export a LaTeX table for Overleaf
balance_xt <- xtable(
  balance_table,
  caption = "Balance Test: Means by Treatment",
  label   = "tab:balance_latino"
)

print(
  balance_xt,
  type              = "latex",
  file              = "balance_table_latino.tex",
  include.rownames  = FALSE,
  booktabs          = TRUE,
  caption.placement = "top"
)
```


#Table 4: South Asian Balance Table
```{r Balance Table Asian, include=FALSE}

# 1. Create a new factor for the balance table only
asian_data$treatment_balance_table <- factor(
  asian_data$treatment,
  labels = c("Control", "Ethnicity", "Immigrant")
)

# 2. Specify your variables and their display labels
vars       <- c("age", "income", "education", "female", "native_born")
var_labels <- c("Age", "Income", "Education", "Female", "Native Born")

# 3. Aggregate means by the new treatment_balance_table
agg <- aggregate(
  asian_data[, vars],
  by = list(Treatment = asian_data$treatment_balance_table),
  FUN = function(x) mean(x, na.rm = TRUE)
)
colnames(agg)[1] <- "Treatment"

# 4. Transpose so each variable is a row, treatments are columns
mean_mat <- t(as.matrix(agg[ , -1]))
colnames(mean_mat) <- as.character(agg$Treatment)
rownames(mean_mat) <- vars

mean_df <- data.frame(
  Variable = var_labels,
  round(as.data.frame(mean_mat, stringsAsFactors = FALSE), 2),
  stringsAsFactors = FALSE,
  row.names = NULL
)

# 5. Build the final “N” row so its columns exactly match mean_df
counts   <- table(asian_data$treatment_balance_table)
count_df <- as.data.frame(
  t(as.numeric(counts)),
  stringsAsFactors = FALSE
)
colnames(count_df) <- names(counts)
count_df$Variable <- "N"

# reorder count_df to have the same columns (and order) as mean_df
count_df <- count_df[ , colnames(mean_df)]

# 6. Combine means + N without error
balance_table <- rbind(mean_df, count_df)

# 7. Print a nice HTML table in R/RMarkdown
balance_table %>%
  kable(
    format    = "html",
    digits    = 2,
    col.names = colnames(balance_table),
    caption   = "Balance Test: Means by Treatment"
  ) %>%
  kable_styling(
    full_width        = FALSE,
    bootstrap_options = c("striped", "hover")
  )

# 8. Export a LaTeX table for Overleaf
balance_xt <- xtable(
  balance_table,
  caption = "Balance Test: Means by Treatment",
  label   = "tab:balance_asian"
)

print(
  balance_xt,
  type              = "latex",
  file              = "balance_table_asian.tex",
  include.rownames  = FALSE,
  booktabs          = TRUE,
  caption.placement = "top"
)
```



#Latino Emotions: Sad
```{r Latino:Sad ATE,  include=FALSE}
# Full sample (OLS)
summary(sad_full<- lm(sad~treatment, latino_data))
#Extract ATES with 95% CIs
fx.sad_full <- as.data.frame(cbind(sad_full$coefficients, confint(sad_full))[2:3,])
names(fx.sad_full) <- c("ate", "ci_l", "ci_u")
fx.sad_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.sad_full$cond <- factor(fx.sad_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.sad_full <-fx.sad_full %>% 
  mutate(type="Sad", group="Full Sample") 
fx.sad_full

# Subset to those who passed manipulation check
summary(sad_mcheck<- lm(sad~treatment, latino_data,subset=latino_data$manipulation_topic==1))


# Native Born
summary(sad_native<- lm(sad~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.sad_native<- as.data.frame(cbind(sad_native$coefficients, confint(sad_native))[2:3,])
names(fx.sad_native) <- c("ate", "ci_l", "ci_u")
fx.sad_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.sad_native$cond <- factor(fx.sad_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.sad_native <-fx.sad_native %>% 
  mutate(type="Sad",group="Native Born") 
fx.sad_native

#Native Born with controls 
summary(sad_native_controls<- lm(sad~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(sad_native_controls_mcheck<- lm(sad~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(sad_foreign<- lm(sad~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.sad_foreign<- as.data.frame(cbind(sad_foreign$coefficients, confint(sad_foreign))[2:3,])
names(fx.sad_foreign) <- c("ate", "ci_l", "ci_u")
fx.sad_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.sad_foreign$cond <- factor(fx.sad_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.sad_foreign <-fx.sad_foreign %>% 
  mutate(type="Sad", group="Foreign Born") 
fx.sad_foreign

#Foreign Born with controls 
summary(sad_foreign_controls<- lm(sad~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(sad_foreign_controls_mcheck<- lm(sad~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))



#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(sad_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_sad_full<-lm(sad~EthTreatment+ EconTreatment, latino_data))
fx.ltest_sad_full <- as.data.frame(cbind(ltest_sad_full$coefficients, confint(ltest_sad_full)))[2,]
names(fx.ltest_sad_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_sad_full$cond <- c("Latino Treatment")
fx.ltest_sad_full <-fx.ltest_sad_full %>% 
  mutate(type="Sad", group="Full Sample") 
fx.ltest_sad_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_sad_native<-lm(sad~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_sad_native <- as.data.frame(cbind(ltest_sad_native$coefficients, confint(ltest_sad_native)))[2,]
names(fx.ltest_sad_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_sad_native$cond <- c("Latino Treatment")
fx.ltest_sad_native <-fx.ltest_sad_native %>% 
  mutate(type="Sad", group="Native Born") 
fx.ltest_sad_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_sad_foreign<-lm(sad~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_sad_foreign <- as.data.frame(cbind(ltest_sad_foreign$coefficients, confint(ltest_sad_foreign)))[2,]
names(fx.ltest_sad_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_sad_foreign$cond <- c("Latino Treatment")
fx.ltest_sad_foreign <-fx.ltest_sad_foreign %>% 
  mutate(type="Sad", group="Foreign Born") 
fx.ltest_sad_foreign

##Put together ltest ATES for plot
pred_latino_sad_ltest<- rbind(fx.ltest_sad_full, fx.ltest_sad_native, fx.ltest_sad_foreign)

```


#Latino Emotions: Afraid
```{r Latino:Afraid ATE,  include=FALSE}
# Full sample (OLS)
summary(afraid_full<- lm(afraid~treatment, latino_data))
#Extract ATES with 95% CIs
fx.afraid_full <- as.data.frame(cbind(afraid_full$coefficients, confint(afraid_full))[2:3,])
names(fx.afraid_full) <- c("ate", "ci_l", "ci_u")
fx.afraid_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.afraid_full$cond <- factor(fx.afraid_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.afraid_full <-fx.afraid_full %>% 
  mutate(type="Afraid", group="Full Sample") 
fx.afraid_full

# Subset to those who passed manipulation check
summary(afraid_mcheck<- lm(afraid~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(afraid_native<- lm(afraid~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.afraid_native<- as.data.frame(cbind(afraid_native$coefficients, confint(afraid_native))[2:3,])
names(fx.afraid_native) <- c("ate", "ci_l", "ci_u")
fx.afraid_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.afraid_native$cond <- factor(fx.afraid_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.afraid_native <-fx.afraid_native %>% 
  mutate(type="Afraid", group="Native Born") 
fx.afraid_native

#Native Born with controls 
summary(afraid_native_controls<- lm(afraid~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(afraid_native_controls_mcheck<- lm(afraid~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(afraid_foreign<- lm(afraid~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.afraid_foreign<- as.data.frame(cbind(afraid_foreign$coefficients, confint(afraid_foreign))[2:3,])
names(fx.afraid_foreign) <- c("ate", "ci_l", "ci_u")
fx.afraid_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.afraid_foreign$cond <- factor(fx.afraid_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.afraid_foreign <-fx.afraid_foreign %>% 
  mutate(type="Afraid", group="Foreign Born") 
fx.afraid_foreign

#Foreign Born with controls 
summary(afraid_foreign_controls<- lm(afraid~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(afraid_foreign_controls_mcheck<- lm(afraid~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))

#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(afraid_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_afraid_full<-lm(afraid~EthTreatment+ EconTreatment, latino_data))
fx.ltest_afraid_full <- as.data.frame(cbind(ltest_afraid_full$coefficients, confint(ltest_afraid_full)))[2,]
names(fx.ltest_afraid_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_afraid_full$cond <- c("Latino Treatment")
fx.ltest_afraid_full <-fx.ltest_afraid_full %>% 
  mutate(type="Afraid", group="Full Sample") 
fx.ltest_afraid_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_afraid_native<-lm(afraid~EthTreatment+ EconTreatment + female + education + 
                                 income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_afraid_native <- as.data.frame(cbind(ltest_afraid_native$coefficients, confint(ltest_afraid_native)))[2,]
names(fx.ltest_afraid_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_afraid_native$cond <- c("Latino Treatment")
fx.ltest_afraid_native <-fx.ltest_afraid_native %>% 
  mutate(type="Afraid", group="Native Born") 
fx.ltest_afraid_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_afraid_foreign<-lm(afraid~EthTreatment+ EconTreatment + female + education + 
                                  income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_afraid_foreign <- as.data.frame(cbind(ltest_afraid_foreign$coefficients, confint(ltest_afraid_foreign)))[2,]
names(fx.ltest_afraid_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_afraid_foreign$cond <- c("Latino Treatment")
fx.ltest_afraid_foreign <-fx.ltest_afraid_foreign %>% 
  mutate(type="Afraid", group="Foreign Born") 
fx.ltest_afraid_foreign

##Put together ltest ATES for plot
pred_latino_afraid_ltest<- rbind(fx.ltest_afraid_full, fx.ltest_afraid_native, fx.ltest_afraid_foreign)

```


#Latino Emotions: Angry
```{r Latino:Angry ATE,  include=FALSE}
# Full sample (OLS)
summary(angry_full<- lm(angry~treatment, latino_data))
#Extract ATES with 95% CIs
fx.angry_full <- as.data.frame(cbind(angry_full$coefficients, confint(angry_full))[2:3,])
names(fx.angry_full) <- c("ate", "ci_l", "ci_u")
fx.angry_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.angry_full$cond <- factor(fx.angry_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.angry_full <-fx.angry_full %>% 
  mutate(type="Angry", group="Full Sample") 
fx.angry_full

# Subset to those who passed manipulation check
summary(angry_mcheck<- lm(angry~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(angry_native<- lm(angry~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.angry_native<- as.data.frame(cbind(angry_native$coefficients, confint(angry_native))[2:3,])
names(fx.angry_native) <- c("ate", "ci_l", "ci_u")
fx.angry_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.angry_native$cond <- factor(fx.angry_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.angry_native <-fx.angry_native %>% 
  mutate(type="Angry", group="Native Born") 
fx.angry_native

#Native Born with controls 
summary(angry_native_controls<- lm(angry~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(angry_native_controls_mcheck<- lm(angry~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(angry_foreign<- lm(angry~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.angry_foreign<- as.data.frame(cbind(angry_foreign$coefficients, confint(angry_foreign))[2:3,])
names(fx.angry_foreign) <- c("ate", "ci_l", "ci_u")
fx.angry_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.angry_foreign$cond <- factor(fx.angry_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.angry_foreign <-fx.angry_foreign %>% 
  mutate(type="Angry", group="Foreign Born") 
fx.angry_foreign

#Foreign Born with controls 
summary(angry_foreign_controls<- lm(angry~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(angry_foreign_controls_mcheck<- lm(angry~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))

#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(angry_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_angry_full<-lm(angry~EthTreatment+ EconTreatment, latino_data))
fx.ltest_angry_full <- as.data.frame(cbind(ltest_angry_full$coefficients, confint(ltest_angry_full)))[2,]
names(fx.ltest_angry_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_angry_full$cond <- c("Latino Treatment")
fx.ltest_angry_full <-fx.ltest_angry_full %>% 
  mutate(type="Angry", group="Full Sample") 
fx.ltest_angry_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_angry_native<-lm(angry~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_angry_native <- as.data.frame(cbind(ltest_angry_native$coefficients, confint(ltest_angry_native)))[2,]
names(fx.ltest_angry_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_angry_native$cond <- c("Latino Treatment")
fx.ltest_angry_native <-fx.ltest_angry_native %>% 
  mutate(type="Angry", group="Native Born") 
fx.ltest_angry_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_angry_foreign<-lm(angry~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_angry_foreign <- as.data.frame(cbind(ltest_angry_foreign$coefficients, confint(ltest_angry_foreign)))[2,]
names(fx.ltest_angry_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_angry_foreign$cond <- c("Latino Treatment")
fx.ltest_angry_foreign <-fx.ltest_angry_foreign %>% 
  mutate(type="Angry", group="Foreign Born") 
fx.ltest_angry_foreign

##Put together ltest ATES for plot
pred_latino_angry_ltest<- rbind(fx.ltest_angry_full, fx.ltest_angry_native, fx.ltest_angry_foreign)

```


#Latino Emotions: Enthus
```{r Latino:Enthus ATE,  include=FALSE}
# Full sample (OLS)
summary(enthus_full<- lm(enthus~treatment, latino_data))
#Extract ATES with 95% CIs
fx.enthus_full <- as.data.frame(cbind(enthus_full$coefficients, confint(enthus_full))[2:3,])
names(fx.enthus_full) <- c("ate", "ci_l", "ci_u")
fx.enthus_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.enthus_full$cond <- factor(fx.enthus_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.enthus_full <-fx.enthus_full %>% 
  mutate(type="Enthusiastic", group="Full Sample") 
fx.enthus_full

# Subset to those who passed manipulation check
summary(enthus_mcheck<- lm(enthus~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(enthus_native<- lm(enthus~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.enthus_native<- as.data.frame(cbind(enthus_native$coefficients, confint(enthus_native))[2:3,])
names(fx.enthus_native) <- c("ate", "ci_l", "ci_u")
fx.enthus_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.enthus_native$cond <- factor(fx.enthus_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.enthus_native <-fx.enthus_native %>% 
  mutate(type="Enthusiastic", group="Native Born") 
fx.enthus_native

#Native Born with controls 
summary(enthus_native_controls<- lm(enthus~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(enthus_native_controls_mcheck<- lm(enthus~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(enthus_foreign<- lm(enthus~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.enthus_foreign<- as.data.frame(cbind(enthus_foreign$coefficients, confint(enthus_foreign))[2:3,])
names(fx.enthus_foreign) <- c("ate", "ci_l", "ci_u")
fx.enthus_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.enthus_foreign$cond <- factor(fx.enthus_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.enthus_foreign <-fx.enthus_foreign %>% 
  mutate(type="Enthusiastic", group="Foreign Born") 
fx.enthus_foreign

#Foreign Born with controls 
summary(enthus_foreign_controls<- lm(enthus~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(enthus_foreign_controls_mcheck<- lm(enthus~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))


#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(enthus_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_enthus_full<-lm(enthus~EthTreatment+ EconTreatment, latino_data))
fx.ltest_enthus_full <- as.data.frame(cbind(ltest_enthus_full$coefficients, confint(ltest_enthus_full)))[2,]
names(fx.ltest_enthus_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_enthus_full$cond <- c("Latino Treatment")
fx.ltest_enthus_full <-fx.ltest_enthus_full %>% 
  mutate(type="Enthus", group="Full Sample") 
fx.ltest_enthus_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_enthus_native<-lm(enthus~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_enthus_native <- as.data.frame(cbind(ltest_enthus_native$coefficients, confint(ltest_enthus_native)))[2,]
names(fx.ltest_enthus_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_enthus_native$cond <- c("Latino Treatment")
fx.ltest_enthus_native <-fx.ltest_enthus_native %>% 
  mutate(type="Enthus", group="Native Born") 
fx.ltest_enthus_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_enthus_foreign<-lm(enthus~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_enthus_foreign <- as.data.frame(cbind(ltest_enthus_foreign$coefficients, confint(ltest_enthus_foreign)))[2,]
names(fx.ltest_enthus_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_enthus_foreign$cond <- c("Latino Treatment")
fx.ltest_enthus_foreign <-fx.ltest_enthus_foreign %>% 
  mutate(type="Enthus", group="Foreign Born") 
fx.ltest_enthus_foreign

##Put together ltest ATES for plot
pred_latino_enthus_ltest<- rbind(fx.ltest_enthus_full, fx.ltest_enthus_native, fx.ltest_enthus_foreign)


```


#Latino Emotions: Hopeful
```{r Latino:Hopeful ATE,  include=FALSE}
# Full sample (OLS)
summary(hopeful_full<- lm(hopeful~treatment, latino_data))
#Extract ATES with 95% CIs
fx.hopeful_full <- as.data.frame(cbind(hopeful_full$coefficients, confint(hopeful_full))[2:3,])
names(fx.hopeful_full) <- c("ate", "ci_l", "ci_u")
fx.hopeful_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.hopeful_full$cond <- factor(fx.hopeful_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.hopeful_full <-fx.hopeful_full %>% 
  mutate(type="Hopeful", group="Full Sample") 
fx.hopeful_full

# Subset to those who passed manipulation check
summary(hopeful_mcheck<- lm(hopeful~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(hopeful_native<- lm(hopeful~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.hopeful_native<- as.data.frame(cbind(hopeful_native$coefficients, confint(hopeful_native))[2:3,])
names(fx.hopeful_native) <- c("ate", "ci_l", "ci_u")
fx.hopeful_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.hopeful_native$cond <- factor(fx.hopeful_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.hopeful_native <-fx.hopeful_native %>% 
  mutate(type="Hopeful", group="Native Born") 
fx.hopeful_native

#Native Born with controls 
summary(hopeful_native_controls<- lm(hopeful~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(hopeful_native_controls_mcheck<- lm(hopeful~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(hopeful_foreign<- lm(hopeful~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.hopeful_foreign<- as.data.frame(cbind(hopeful_foreign$coefficients, confint(hopeful_foreign))[2:3,])
names(fx.hopeful_foreign) <- c("ate", "ci_l", "ci_u")
fx.hopeful_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.hopeful_foreign$cond <- factor(fx.hopeful_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.hopeful_foreign <-fx.hopeful_foreign %>% 
  mutate(type="Hopeful", group="Foreign Born") 
fx.hopeful_foreign

#Foreign Born with controls 
summary(hopeful_foreign_controls<- lm(hopeful~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(hopeful_foreign_controls_mcheck<- lm(hopeful~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))


#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(hopeful_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_hopeful_full<-lm(hopeful~EthTreatment+ EconTreatment, latino_data))
fx.ltest_hopeful_full <- as.data.frame(cbind(ltest_hopeful_full$coefficients, confint(ltest_hopeful_full)))[2,]
names(fx.ltest_hopeful_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_hopeful_full$cond <- c("Latino Treatment")
fx.ltest_hopeful_full <-fx.ltest_hopeful_full %>% 
  mutate(type="Hopeful", group="Full Sample") 
fx.ltest_hopeful_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_hopeful_native<-lm(hopeful~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_hopeful_native <- as.data.frame(cbind(ltest_hopeful_native$coefficients, confint(ltest_hopeful_native)))[2,]
names(fx.ltest_hopeful_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_hopeful_native$cond <- c("Latino Treatment")
fx.ltest_hopeful_native <-fx.ltest_hopeful_native %>% 
  mutate(type="Hopeful", group="Native Born") 
fx.ltest_hopeful_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_hopeful_foreign<-lm(hopeful~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_hopeful_foreign <- as.data.frame(cbind(ltest_hopeful_foreign$coefficients, confint(ltest_hopeful_foreign)))[2,]
names(fx.ltest_hopeful_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_hopeful_foreign$cond <- c("Latino Treatment")
fx.ltest_hopeful_foreign <-fx.ltest_hopeful_foreign %>% 
  mutate(type="Hopeful", group="Foreign Born") 
fx.ltest_hopeful_foreign

##Put together ltest ATES for plot
pred_latino_hopeful_ltest<- rbind(fx.ltest_hopeful_full, fx.ltest_hopeful_native, fx.ltest_hopeful_foreign)

```


#B.1 Table 5: Emotions ATEs (Full Latino Sample)
```{r Latino:Sad Table Full, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
modellabels<-c("Latino Treatment", "Immigrant Treatment")
stargazer(sad_full, angry_full, afraid_full, enthus_full, hopeful_full,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Emotion ATEs (Full Sample)",       
          label = "latino_emotion_full", 
          column.labels = c("Sad", "Angry", "Afraid", "Enthusiastic", "Hopeful"))

```


#C.1 Table 17: Emotion ATEs (Latino Sample + Manipulation Check)
```{r Latino:Sad Table Full + Mcheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}

#Stargzer error when models names are too long (fix below)

# 1. Collect your existing models into a list
old_models <- list(
  sad_mcheck,
  angry_mcheck,
  afraid_mcheck,
  enthus_mcheck,
  hopeful_mcheck
)

# 2. Assign them to m1, m2, m3, m4, m5 in your workspace
for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("Latino Treatment", "Immigrant Treatment")
stargazer(m1, m2, m3, m4, m5,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Emotion ATEs (Full Sample + Passed Mcheck)",   
          label = "latino_emotion_full_mcheck", 
          column.labels = c("Sad", "Angry","Afraid", "Enthusiastic", "Hopeful"))
```


#B.1 Table 6: Emotion ATEs (Native Born Latinos)
```{r Latino:Sad Table Native Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
#Stargzer error when models names are too long (fix below)

# 1. Collect your existing models into a list
old_models <- list(
sad_native, sad_native_controls, angry_native, angry_native_controls, afraid_native, afraid_native_controls, enthus_native, enthus_native_controls, hopeful_native, hopeful_native_controls
)

# 2. Assign them to m1, m2, m3, m4, m5 in your workspace
for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}


modellabels<-c("Latino Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Mexican", "English L.", "Pol. Interest" )
stargazer( m1, m2, m3, m4, m5,m6, m7, m8, m9, m10,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Emotion ATEs (Native Born Only)",   
          label = "latino_emotion_native", 
          column.labels = c("Sad", "Sad", "Angry", "Angry", "Afraid", "Afraid","Enthus", "Enthus", "Hopeful", "Hopeful"))
```

#B.1 Table 7: Emotion ATEs (Foreign Born Latinos)
```{r Latino:Sad Table Foreign Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
#Stargzer error when models names are too long (fix below)

# 1. Collect your existing models into a list
old_models <- list(
sad_foreign, sad_foreign_controls, angry_foreign, angry_foreign_controls, afraid_foreign, afraid_foreign_controls, enthus_foreign, enthus_foreign_controls, hopeful_foreign, hopeful_foreign_controls
)

# 2. Assign them to m1, m2, m3, m4, m5 in your workspace
for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("Latino Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Mexican", "English L.", "Pol. Interest" )
stargazer( m1, m2, m3, m4, m5,m6, m7, m8, m9, m10,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Emotion ATEs (Foreign Born Only)",   
          label = "latino_emotion_foreign", 
          column.labels = c("Sad", "Sad", "Angry", "Angry", "Afraid", "Afraid", "Enthus", "Enthus", "Hopeful", "Hopeful"))
```


#C.1 Table 17: Latino Emotion ATEs (By Nativity + Manipulation Check)
```{r Latino:Sad Table Nativity+MCheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
# 1. Collect your existing models into a list
old_models <- list(sad_native_controls_mcheck, sad_foreign_controls_mcheck, angry_native_controls_mcheck, angry_foreign_controls_mcheck, afraid_native_controls_mcheck, afraid_foreign_controls_mcheck, enthus_native_controls_mcheck, enthus_foreign_controls_mcheck, hopeful_native_controls_mcheck
)

# 2. Assign them to m1, m2, m3, m4, m5 in your workspace
for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("Latino Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Mexican", "English L.", "Pol. Interest" )
stargazer( m1, m2, m3, m4, m5,m6, m7, m8, m9, m10,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Emotion ATEs (By Natvivity + Passed Mcheck)",   
          label = "latino_emotion_nativity_mcheck", 
          column.labels = c("Sad", "Sad", "Angry", "Angry", "Afraid", "Afraid", "Enthus", "Enthus", "Hopeful", "Hopeful"))
```


#Latino Emotion Plot Full Sample
```{r Latino:Emotion Plot Full , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_latino_emotion_full<- rbind(fx.sad_full, fx.angry_full, fx.afraid_full, fx.enthus_full, fx.hopeful_full)

##This ensures the order of graphs are in the way in which we want them
pred_latino_emotion_full$type_f = factor(pred_latino_emotion_full$type, levels=c('Hopeful','Enthusiastic','Afraid','Angry', 'Sad'))

s1<-ggplot(pred_latino_emotion_full, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	#geom_errorbar(width=.12, alpha=1) +
	#geom_point(size=3, shape=21) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("Latino", "Immigrant")) +
  scale_shape(labels = c("Latino", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.4,.4), breaks=c(-.4, -.3, -.2, -.1, 0, .1, .2, .3, .4)) +
	ylab("Diff. in Emotion (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~group) +
  theme(legend.position = "bottom")

ggsave(filename = "latino_emotion_full.png", plot = s1, width = 8, height = 5)

```

#Figure 1: Emotion ATEs, Latino Sample by Nativity
```{r Latino:Emotion Plot Nativity , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_latino_emotion_nativity<- rbind(fx.sad_native,fx.sad_foreign,fx.angry_native,fx.angry_foreign, fx.afraid_native,fx.afraid_foreign,  fx.enthus_native,fx.enthus_foreign, fx.hopeful_native, fx.hopeful_foreign)

##This ensures the order of graphs are in the way in which we want them
pred_latino_emotion_nativity$type_f = factor(pred_latino_emotion_nativity$type, levels=c('Hopeful', 'Enthusiastic', 'Afraid', 'Angry', 'Sad'))

s1<-ggplot(pred_latino_emotion_nativity, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	#geom_errorbar(width=.12, alpha=1) +
	#geom_point(size=3, shape=21) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("Latino", "Immigrant")) +
  scale_shape(labels = c("Latino", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.4,.45), breaks=c( -.4, -.3, -.2, -.1, 0, .1, .2, .3, .4)) +
	ylab("Diff. in Emotion (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~factor(group, levels=c("Native Born", "Foreign Born"))) +
  theme(legend.position = "bottom")

ggsave("latino_emotion_nativity.png", plot=s1,
         width = 8, height = 5)
```


#Latino Trait: Cares
```{r Latino: Cares ATE,  include=FALSE}
# Full sample (OLS)
summary(cares_full<- lm(cares~treatment, latino_data))
#Extract ATES with 95% CIs
fx.cares_full <- as.data.frame(cbind(cares_full$coefficients, confint(cares_full))[2:3,])
names(fx.cares_full) <- c("ate", "ci_l", "ci_u")
fx.cares_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.cares_full$cond <- factor(fx.cares_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.cares_full <-fx.cares_full %>% 
  mutate(type="Cares", group="Full Sample") 
fx.cares_full

# Subset to those who passed manipulation check
summary(cares_mcheck<- lm(cares~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(cares_native<- lm(cares~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.cares_native<- as.data.frame(cbind(cares_native$coefficients, confint(cares_native))[2:3,])
names(fx.cares_native) <- c("ate", "ci_l", "ci_u")
fx.cares_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.cares_native$cond <- factor(fx.cares_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.cares_native <-fx.cares_native %>% 
  mutate(type="Cares",group="Native Born") 
fx.cares_native

#Native Born with controls 
summary(cares_native_controls<- lm(cares~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(cares_native_controls_mcheck<- lm(cares~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(cares_foreign<- lm(cares~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.cares_foreign<- as.data.frame(cbind(cares_foreign$coefficients, confint(cares_foreign))[2:3,])
names(fx.cares_foreign) <- c("ate", "ci_l", "ci_u")
fx.cares_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.cares_foreign$cond <- factor(fx.cares_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.cares_foreign <-fx.cares_foreign %>% 
  mutate(type="Cares", group="Foreign Born") 
fx.cares_foreign

#Foreign Born with controls 
summary(cares_foreign_controls<- lm(cares~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(cares_foreign_controls_mcheck<- lm(cares~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))

#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(cares_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_cares_full<-lm(cares~EthTreatment+ EconTreatment, latino_data))
fx.ltest_cares_full <- as.data.frame(cbind(ltest_cares_full$coefficients, confint(ltest_cares_full)))[2,]
names(fx.ltest_cares_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_cares_full$cond <- c("Latino Treatment")
fx.ltest_cares_full <-fx.ltest_cares_full %>% 
  mutate(type="Cares", group="Full Sample") 
fx.ltest_cares_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_cares_native<-lm(cares~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_cares_native <- as.data.frame(cbind(ltest_cares_native$coefficients, confint(ltest_cares_native)))[2,]
names(fx.ltest_cares_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_cares_native$cond <- c("Latino Treatment")
fx.ltest_cares_native <-fx.ltest_cares_native %>% 
  mutate(type="Cares", group="Native Born") 
fx.ltest_cares_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_cares_foreign<-lm(cares~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_cares_foreign <- as.data.frame(cbind(ltest_cares_foreign$coefficients, confint(ltest_cares_foreign)))[2,]
names(fx.ltest_cares_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_cares_foreign$cond <- c("Latino Treatment")
fx.ltest_cares_foreign <-fx.ltest_cares_foreign %>% 
  mutate(type="Cares", group="Foreign Born") 
fx.ltest_cares_foreign

##Put together ltest ATES for plot
pred_latino_cares_ltest<- rbind(fx.ltest_cares_full, fx.ltest_cares_native, fx.ltest_cares_foreign)

```

#Latino Trait: Honest
```{r Latino: Honest ATE,  include=FALSE}
# Full sample (OLS)
summary(honest_full<- lm(honest~treatment, latino_data))
#Extract ATES with 95% CIs
fx.honest_full <- as.data.frame(cbind(honest_full$coefficients, confint(honest_full))[2:3,])
names(fx.honest_full) <- c("ate", "ci_l", "ci_u")
fx.honest_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.honest_full$cond <- factor(fx.honest_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.honest_full <-fx.honest_full %>% 
  mutate(type="Honest", group="Full Sample") 
fx.honest_full

# Subset to those who passed manipulation check
summary(honest_mcheck<- lm(honest~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(honest_native<- lm(honest~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.honest_native<- as.data.frame(cbind(honest_native$coefficients, confint(honest_native))[2:3,])
names(fx.honest_native) <- c("ate", "ci_l", "ci_u")
fx.honest_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.honest_native$cond <- factor(fx.honest_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.honest_native <-fx.honest_native %>% 
  mutate(type="Honest",group="Native Born") 
fx.honest_native

#Native Born with controls 
summary(honest_native_controls<- lm(honest~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(honest_native_controls_mcheck<- lm(honest~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(honest_foreign<- lm(honest~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.honest_foreign<- as.data.frame(cbind(honest_foreign$coefficients, confint(honest_foreign))[2:3,])
names(fx.honest_foreign) <- c("ate", "ci_l", "ci_u")
fx.honest_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.honest_foreign$cond <- factor(fx.honest_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.honest_foreign <-fx.honest_foreign %>% 
  mutate(type="Honest", group="Foreign Born") 
fx.honest_foreign

#Foreign Born with controls 
summary(honest_foreign_controls<- lm(honest~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(honest_foreign_controls_mcheck<- lm(honest~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))



#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(honest_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_honest_full<-lm(honest~EthTreatment+ EconTreatment, latino_data))
fx.ltest_honest_full <- as.data.frame(cbind(ltest_honest_full$coefficients, confint(ltest_honest_full)))[2,]
names(fx.ltest_honest_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_honest_full$cond <- c("Latino Treatment")
fx.ltest_honest_full <-fx.ltest_honest_full %>% 
  mutate(type="Honest", group="Full Sample") 
fx.ltest_honest_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_honest_native<-lm(honest~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_honest_native <- as.data.frame(cbind(ltest_honest_native$coefficients, confint(ltest_honest_native)))[2,]
names(fx.ltest_honest_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_honest_native$cond <- c("Latino Treatment")
fx.ltest_honest_native <-fx.ltest_honest_native %>% 
  mutate(type="Honest", group="Native Born") 
fx.ltest_honest_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_honest_foreign<-lm(honest~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_honest_foreign <- as.data.frame(cbind(ltest_honest_foreign$coefficients, confint(ltest_honest_foreign)))[2,]
names(fx.ltest_honest_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_honest_foreign$cond <- c("Latino Treatment")
fx.ltest_honest_foreign <-fx.ltest_honest_foreign %>% 
  mutate(type="Honest", group="Foreign Born") 
fx.ltest_honest_foreign

##Put together ltest ATES for plot
pred_latino_honest_ltest<- rbind(fx.ltest_honest_full, fx.ltest_honest_native, fx.ltest_honest_foreign)

```


#Latino Trait: Hardworking
```{r Latino: Hardworking ATE,  include=FALSE}
# Full sample (OLS)
summary(hardworking_full<- lm(hardworking~treatment, latino_data))
#Extract ATES with 95% CIs
fx.hardworking_full <- as.data.frame(cbind(hardworking_full$coefficients, confint(hardworking_full))[2:3,])
names(fx.hardworking_full) <- c("ate", "ci_l", "ci_u")
fx.hardworking_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.hardworking_full$cond <- factor(fx.hardworking_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.hardworking_full <-fx.hardworking_full %>% 
  mutate(type="Hardworking", group="Full Sample") 
fx.hardworking_full

# Subset to those who passed manipulation check
summary(hardworking_mcheck<- lm(hardworking~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(hardworking_native<- lm(hardworking~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.hardworking_native<- as.data.frame(cbind(hardworking_native$coefficients, confint(hardworking_native))[2:3,])
names(fx.hardworking_native) <- c("ate", "ci_l", "ci_u")
fx.hardworking_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.hardworking_native$cond <- factor(fx.hardworking_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.hardworking_native <-fx.hardworking_native %>% 
  mutate(type="Hardworking",group="Native Born") 
fx.hardworking_native

#Native Born with controls 
summary(hardworking_native_controls<- lm(hardworking~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(hardworking_native_controls_mcheck<- lm(hardworking~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(hardworking_foreign<- lm(hardworking~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.hardworking_foreign<- as.data.frame(cbind(hardworking_foreign$coefficients, confint(hardworking_foreign))[2:3,])
names(fx.hardworking_foreign) <- c("ate", "ci_l", "ci_u")
fx.hardworking_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.hardworking_foreign$cond <- factor(fx.hardworking_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.hardworking_foreign <-fx.hardworking_foreign %>% 
  mutate(type="Hardworking", group="Foreign Born") 
fx.hardworking_foreign

#Foreign Born with controls 
summary(hardworking_foreign_controls<- lm(hardworking~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(hardworking_foreign_controls_mcheck<- lm(hardworking~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))


#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(hardworking_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_hardworking_full<-lm(hardworking~EthTreatment+ EconTreatment, latino_data))
fx.ltest_hardworking_full <- as.data.frame(cbind(ltest_hardworking_full$coefficients, confint(ltest_hardworking_full)))[2,]
names(fx.ltest_hardworking_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_hardworking_full$cond <- c("Latino Treatment")
fx.ltest_hardworking_full <-fx.ltest_hardworking_full %>% 
  mutate(type="Hardworking", group="Full Sample") 
fx.ltest_hardworking_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_hardworking_native<-lm(hardworking~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_hardworking_native <- as.data.frame(cbind(ltest_hardworking_native$coefficients, confint(ltest_hardworking_native)))[2,]
names(fx.ltest_hardworking_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_hardworking_native$cond <- c("Latino Treatment")
fx.ltest_hardworking_native <-fx.ltest_hardworking_native %>% 
  mutate(type="Hardworking", group="Native Born") 
fx.ltest_hardworking_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_hardworking_foreign<-lm(hardworking~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_hardworking_foreign <- as.data.frame(cbind(ltest_hardworking_foreign$coefficients, confint(ltest_hardworking_foreign)))[2,]
names(fx.ltest_hardworking_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_hardworking_foreign$cond <- c("Latino Treatment")
fx.ltest_hardworking_foreign <-fx.ltest_hardworking_foreign %>% 
  mutate(type="Hardworking", group="Foreign Born") 
fx.ltest_hardworking_foreign

##Put together ltest ATES for plot
pred_latino_hardworking_ltest<- rbind(fx.ltest_hardworking_full, fx.ltest_hardworking_native, fx.ltest_hardworking_foreign)

```


#Latino Vote Stevens
```{r Latino: VoteStevens ATE,  include=FALSE}
# Full sample (OLS)
summary(voteStevens_full<- lm(voteStevens~treatment, latino_data))
#Extract ATES with 95% CIs
fx.voteStevens_full <- as.data.frame(cbind(voteStevens_full$coefficients, confint(voteStevens_full))[2:3,])
names(fx.voteStevens_full) <- c("ate", "ci_l", "ci_u")
fx.voteStevens_full$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.voteStevens_full$cond <- factor(fx.voteStevens_full$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.voteStevens_full <-fx.voteStevens_full %>% 
  mutate(type="VoteStevens", group="Full Sample") 
fx.voteStevens_full

# Subset to those who passed manipulation check
summary(voteStevens_mcheck<- lm(voteStevens~treatment, latino_data,subset=latino_data$manipulation_topic==1))

# Native Born
summary(voteStevens_native<- lm(voteStevens~treatment, latino_data,subset=latino_data$native_born == 1))
#Extract ATES with 95% CIs
fx.voteStevens_native<- as.data.frame(cbind(voteStevens_native$coefficients, confint(voteStevens_native))[2:3,])
names(fx.voteStevens_native) <- c("ate", "ci_l", "ci_u")
fx.voteStevens_native$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.voteStevens_native$cond <- factor(fx.voteStevens_native$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.voteStevens_native <-fx.voteStevens_native %>% 
  mutate(type="VoteStevens",group="Native Born") 
fx.voteStevens_native

#Native Born with controls 
summary(voteStevens_native_controls<- lm(voteStevens~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$native_born == 1))

#Native Born with controls + Mcheck
summary(voteStevens_native_controls_mcheck<- lm(voteStevens~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset=latino_data$manipulation_topic==1 & latino_data$native_born == 1))

# Foreign born
summary(voteStevens_foreign<- lm(voteStevens~treatment, latino_data,subset= latino_data$native_born == 0))
#Extract ATES with 95% CIs
fx.voteStevens_foreign<- as.data.frame(cbind(voteStevens_foreign$coefficients, confint(voteStevens_foreign))[2:3,])
names(fx.voteStevens_foreign) <- c("ate", "ci_l", "ci_u")
fx.voteStevens_foreign$cond <- c("Latino Treatment", "Immigrant Treatment")
fx.voteStevens_foreign$cond <- factor(fx.voteStevens_foreign$cond, levels=c("Latino Treatment", "Immigrant Treatment"))
fx.voteStevens_foreign <-fx.voteStevens_foreign %>% 
  mutate(type="VoteStevens", group="Foreign Born") 
fx.voteStevens_foreign

#Foreign Born with controls 
summary(voteStevens_foreign_controls<- lm(voteStevens~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(voteStevens_foreign_controls_mcheck<- lm(voteStevens~treatment+ female+education+income+age+mexican+ english_lang+interest, latino_data,subset= latino_data$manipulation_topic==1 & latino_data$native_born == 0))



#Latino v. Immigrant Treatment (Full Sample)
linearHypothesis(voteStevens_full, c("treatmentLatino =treatmentImmigrant"))
summary(ltest_voteStevens_full<-lm(voteStevens~EthTreatment+ EconTreatment, latino_data))
fx.ltest_voteStevens_full <- as.data.frame(cbind(ltest_voteStevens_full$coefficients, confint(ltest_voteStevens_full)))[2,]
names(fx.ltest_voteStevens_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_voteStevens_full$cond <- c("Latino Treatment")
fx.ltest_voteStevens_full <-fx.ltest_voteStevens_full %>% 
  mutate(type="VoteStevens", group="Full Sample") 
fx.ltest_voteStevens_full

#Latino v. Immigrant Treatment (Native)
summary(ltest_voteStevens_native<-lm(voteStevens~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 1))
fx.ltest_voteStevens_native <- as.data.frame(cbind(ltest_voteStevens_native$coefficients, confint(ltest_voteStevens_native)))[2,]
names(fx.ltest_voteStevens_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_voteStevens_native$cond <- c("Latino Treatment")
fx.ltest_voteStevens_native <-fx.ltest_voteStevens_native %>% 
  mutate(type="VoteStevens", group="Native Born") 
fx.ltest_voteStevens_native

#Latino v. Immigrant Treatment (Foreign)
summary(ltest_voteStevens_foreign<-lm(voteStevens~EthTreatment+ EconTreatment + female + education + 
    income + age + mexican + english_lang + interest, latino_data, subset= latino_data$native_born == 0))
fx.ltest_voteStevens_foreign <- as.data.frame(cbind(ltest_voteStevens_foreign$coefficients, confint(ltest_voteStevens_foreign)))[2,]
names(fx.ltest_voteStevens_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_voteStevens_foreign$cond <- c("Latino Treatment")
fx.ltest_voteStevens_foreign <-fx.ltest_voteStevens_foreign %>% 
  mutate(type="VoteStevens", group="Foreign Born") 
fx.ltest_voteStevens_foreign

##Put together ltest ATES for plot
pred_latino_voteStevens_ltest<- rbind(fx.ltest_voteStevens_full, fx.ltest_voteStevens_native, fx.ltest_voteStevens_foreign)

```


#B.3 Table 11: Candidate Evaluation ATEs (Full Latino Sample)
```{r Latino: Traits Table Full, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
modellabels<-c("Latino Treatment", "Immigrant Treatment")
stargazer(cares_full, honest_full, hardworking_full, voteStevens_full,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Candidate Trait and Vote Choice ATEs (Full Sample)",       
          label = "latino_trait_full", 
          column.labels = c("Cares", "Honest", "Hardworking", "Vote Stevens"))

```


#C.3 Table 21: Candidate Evaluation ATEs (Latino Sample + Manipulation Check)
```{r Latino: Trait Table Full + Mcheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
modellabels<-c("Latino Treatment", "Immigrant Treatment")
stargazer(cares_mcheck, honest_mcheck, hardworking_mcheck, voteStevens_mcheck,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Candidate Trait and Vote Choice ATEs (Full Sample + Passed Mcheck)",   
          label = "latino_trait_full_mcheck", 
          column.labels = c("Cares", "Honest", "Hardworking", "Vote Stevens"))
```


#B.3 Table 12: Candidate Evaluation ATEs (Native Born Latinos)
```{r Latino:Trait Table Native Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
# 1. Collect your existing models into a list
old_models <- list(cares_native, cares_native_controls, honest_native, honest_native_controls,hardworking_native, hardworking_native_controls, voteStevens_native, voteStevens_native_controls
)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("Latino Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Mexican", "English L.", "Pol. Interest" )
stargazer(m1, m2, m3, m4, m5,m6, m7, m8,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Candidate Trait and Vote Choice ATEs (Native Born Only)",   
          label = "latino_trait_native", 
          column.labels = c("Cares","Cares", "Honest","Honest", "Hardworking","Hardworking", 
                            "Vote","Vote"))
```

#B.3 Table 13: Candidate Evaluation ATEs (Foreign Born Latinos)
```{r Latino: Trait Table Freign Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
# 1. Collect your existing models into a list
old_models <- list(cares_foreign, cares_foreign_controls, honest_foreign, honest_foreign_controls,hardworking_foreign, hardworking_foreign_controls, voteStevens_foreign, voteStevens_foreign_controls
)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("Latino Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Mexican", "English L.", "Pol. Interest" )
stargazer(m1, m2, m3, m4, m5,m6, m7, m8,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Candidate Trait and Vote Choice ATEs (Foreign Born Only)",   
          label = "latino_trait_foreign", 
          column.labels = c("Cares","Cares", "Honest","Honest", "Hardworking","Hardworking", 
                            "Vote","Vote"))
```


#C.3 Table 22: Latino Candidate Evaluation ATEs (By Nativity + Manipulation Check)
```{r Latino: Trait Table Nativity+MCheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
# 1. Collect your existing models into a list
old_models <- list(cares_native_controls_mcheck, cares_foreign_controls_mcheck, honest_native_controls_mcheck, honest_foreign_controls_mcheck, hardworking_native_controls_mcheck, hardworking_foreign_controls_mcheck, voteStevens_native_controls_mcheck, voteStevens_foreign_controls_mcheck
)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("Latino Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Mexican", "English L.", "Pol. Interest" )
stargazer(m1, m2, m3, m4, m5,m6, m7, m8,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "Latino Candidate Trait and Vote Choice ATEs (By Natvivity + Passed Mcheck)",   
          label = "latino_trait_nativity_mcheck", 
          column.labels = c("Cares","Cares", "Honest","Honest", "Hardworking","Hardworking", 
                            "Vote","Vote"))
```


#Latino Trait Plot Full Sample
```{r Latino:Trait Plot Full , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_latino_trait_full<- rbind(fx.cares_full, fx.honest_full, fx.hardworking_full, fx.voteStevens_full)

##This ensures the order of graphs are in the way in which we want them
pred_latino_trait_full$type_f = factor(pred_latino_trait_full$type, levels=c('VoteStevens','Hardworking','Honest', 'Cares'))

s1<-ggplot(pred_latino_trait_full, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("Latino", "Immigrant")) +
  scale_shape(labels = c("Latino", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.4,.1), breaks=c(-.4, -.3, -.2, -.1, 0, .1)) +
	ylab("Diff. in Trait/Vote (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~group) +
  theme(legend.position = "bottom")

  ggsave("latino_trait_full.png", plot = s1,
         width = 8, height = 5)
```


#Figure 2: Candidate Evaluation ATEs, Latino Sample by Nativity
```{r Latino:Trait Plot Nativity , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_latino_trait_nativity<- rbind(fx.cares_native,fx.cares_foreign,fx.honest_native,fx.honest_foreign,  fx.hardworking_native,fx.hardworking_foreign, fx.voteStevens_native, fx.voteStevens_foreign)

##This ensures the order of graphs are in the way in which we want them
pred_latino_trait_nativity$type_f = factor(pred_latino_trait_nativity$type, levels=c('VoteStevens','Hardworking','Honest', 'Cares'))

s1<-ggplot(pred_latino_trait_nativity, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("Latino", "Immigrant")) +
  scale_shape(labels = c("Latino", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.45,.1), breaks=c(-.4, -.3, -.2, -.1, 0, .1)) +
	ylab("Diff. in Trait/Vote (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~factor(group, levels=c("Native Born", "Foreign Born"))) +
  theme(legend.position = "bottom")

  ggsave("latino_trait_nativity.png", plot = s1,
         width = 8, height = 5)

```


#Figure 3: Difference between Panethnic and Immigrant Treatments, Latino Sample by Nativity
```{r Latino:Diff Plot , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot

pred_latino_sad_ltest<- rbind(fx.ltest_sad_native, fx.ltest_sad_foreign)

pred_latino_angry_ltest<- rbind(fx.ltest_angry_native, fx.ltest_angry_foreign)

pred_latino_afraid_ltest<- rbind(fx.ltest_afraid_native, fx.ltest_afraid_foreign)


pred_latino_enthus_ltest<- rbind(fx.ltest_enthus_native, fx.ltest_enthus_foreign)


pred_latino_hopeful_ltest<- rbind(fx.ltest_hopeful_native, fx.ltest_hopeful_foreign)


pred_latino_cares_ltest<- rbind(fx.ltest_cares_native, fx.ltest_cares_foreign)
  
pred_latino_honest_ltest<- rbind(fx.ltest_honest_native, fx.ltest_honest_foreign)

pred_latino_hardworking_ltest<- rbind(fx.ltest_hardworking_native, fx.ltest_hardworking_foreign)

pred_latino_voteStevens_ltest<- rbind(fx.ltest_voteStevens_native, fx.ltest_voteStevens_foreign)


pred_latino_all_ltest<- rbind(pred_latino_sad_ltest,pred_latino_angry_ltest,pred_latino_afraid_ltest, pred_latino_enthus_ltest, pred_latino_hopeful_ltest,pred_latino_cares_ltest, pred_latino_honest_ltest,pred_latino_hardworking_ltest, pred_latino_voteStevens_ltest)

##This ensures the order of graphs are in the way in which we want them
pred_latino_all_ltest$type_f = factor(pred_latino_all_ltest$type, levels=c('VoteStevens','Hardworking','Honest', 'Cares', 'Hopeful', 'Enthus', 'Afraid', 'Angry', 'Sad'))

pred_latino_all_ltest$group <- factor(pred_latino_all_ltest$group, levels = c("Native Born", "Foreign Born"))


s1<-ggplot(pred_latino_all_ltest, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=group, color=group))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("Native Born", "Foreign Born")) +
  scale_shape(labels = c("Native Born", "Foreign Born"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.2,.2), breaks=c(-.2, -.1, 0, .1, .2)) +
	ylab("Latino Treatment compared to Immigrant Treatment") + xlab("") +
  labs(color = "", shape = "") + 
  coord_flip() + 
  facet_wrap(~factor(group, levels=c("Native Born", "Foreign Born"))) +
  theme(legend.position = "bottom")

  ggsave("latino_diff_by_nativity.png", plot = s1,
         width = 8, height = 5)

```



#South Asian Emotions: Sad
```{r South Asian:Sad ATE,  include=FALSE}
# Full sample (OLS)
summary(sad_full<- lm(sad~treatment, asian_data))
#Extract ATES with 95% CIs
fx.sad_full <- as.data.frame(cbind(sad_full$coefficients, confint(sad_full))[2:3,])
names(fx.sad_full) <- c("ate", "ci_l", "ci_u")
fx.sad_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.sad_full$cond <- factor(fx.sad_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.sad_full <-fx.sad_full %>% 
  mutate(type="Sad", group="Full Sample") 
fx.sad_full

# Subset to those who passed manipulation check
summary(sad_mcheck<- lm(sad~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(sad_native<- lm(sad~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.sad_native<- as.data.frame(cbind(sad_native$coefficients, confint(sad_native))[2:3,])
names(fx.sad_native) <- c("ate", "ci_l", "ci_u")
fx.sad_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.sad_native$cond <- factor(fx.sad_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.sad_native <-fx.sad_native %>% 
  mutate(type="Sad",group="Native Born") 
fx.sad_native

#Native Born with controls 
summary(sad_native_controls<- lm(sad~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(sad_native_controls_mcheck<- lm(sad~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(sad_foreign<- lm(sad~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.sad_foreign<- as.data.frame(cbind(sad_foreign$coefficients, confint(sad_foreign))[2:3,])
names(fx.sad_foreign) <- c("ate", "ci_l", "ci_u")
fx.sad_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.sad_foreign$cond <- factor(fx.sad_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.sad_foreign <-fx.sad_foreign %>% 
  mutate(type="Sad", group="Foreign Born") 
fx.sad_foreign

#Foreign Born with controls 
summary(sad_foreign_controls<- lm(sad~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(sad_foreign_controls_mcheck<- lm(sad~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))


#Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(sad_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_sad_full<-lm(sad~EthTreatment+ EconTreatment, asian_data))
fx.ltest_sad_full <- as.data.frame(cbind(ltest_sad_full$coefficients, confint(ltest_sad_full)))[2,]
names(fx.ltest_sad_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_sad_full$cond <- c("South Asian Treatment")
fx.ltest_sad_full <-fx.ltest_sad_full %>% 
  mutate(type="Sad", group="Full Sample") 
fx.ltest_sad_full

#Asian v. Immigrant Treatment (Native)
summary(ltest_sad_native<-lm(sad~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_sad_native <- as.data.frame(cbind(ltest_sad_native$coefficients, confint(ltest_sad_native)))[2,]
names(fx.ltest_sad_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_sad_native$cond <- c("South Asian Treatment")
fx.ltest_sad_native <-fx.ltest_sad_native %>% 
  mutate(type="Sad", group="Native Born") 
fx.ltest_sad_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_sad_foreign<-lm(sad~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_sad_foreign <- as.data.frame(cbind(ltest_sad_foreign$coefficients, confint(ltest_sad_foreign)))[2,]
names(fx.ltest_sad_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_sad_foreign$cond <- c("South Asian Treatment")
fx.ltest_sad_foreign <-fx.ltest_sad_foreign %>% 
  mutate(type="Sad", group="Foreign Born") 
fx.ltest_sad_foreign

##Put together ltest ATES for plot
pred_asian_sad_ltest<- rbind(fx.ltest_sad_full, fx.ltest_sad_native, fx.ltest_sad_foreign)

```


#South Asian Emotions: Afraid
```{r South Asian:Afraid ATE,  include=FALSE}
# Full sample (OLS)
summary(afraid_full<- lm(afraid~treatment, asian_data))
#Extract ATES with 95% CIs
fx.afraid_full <- as.data.frame(cbind(afraid_full$coefficients, confint(afraid_full))[2:3,])
names(fx.afraid_full) <- c("ate", "ci_l", "ci_u")
fx.afraid_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.afraid_full$cond <- factor(fx.afraid_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.afraid_full <-fx.afraid_full %>% 
  mutate(type="Afraid", group="Full Sample") 
fx.afraid_full

# Subset to those who passed manipulation check
summary(afraid_mcheck<- lm(afraid~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(afraid_native<- lm(afraid~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.afraid_native<- as.data.frame(cbind(afraid_native$coefficients, confint(afraid_native))[2:3,])
names(fx.afraid_native) <- c("ate", "ci_l", "ci_u")
fx.afraid_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.afraid_native$cond <- factor(fx.afraid_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.afraid_native <-fx.afraid_native %>% 
  mutate(type="Afraid", group="Native Born") 
fx.afraid_native

#Native Born with controls 
summary(afraid_native_controls<- lm(afraid~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(afraid_native_controls_mcheck<- lm(afraid~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(afraid_foreign<- lm(afraid~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.afraid_foreign<- as.data.frame(cbind(afraid_foreign$coefficients, confint(afraid_foreign))[2:3,])
names(fx.afraid_foreign) <- c("ate", "ci_l", "ci_u")
fx.afraid_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.afraid_foreign$cond <- factor(fx.afraid_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.afraid_foreign <-fx.afraid_foreign %>% 
  mutate(type="Afraid", group="Foreign Born") 
fx.afraid_foreign

#Foreign Born with controls 
summary(afraid_foreign_controls<- lm(afraid~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(afraid_foreign_controls_mcheck<- lm(afraid~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))

#Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(afraid_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_afraid_full<-lm(afraid~EthTreatment+ EconTreatment, asian_data))
fx.ltest_afraid_full <- as.data.frame(cbind(ltest_afraid_full$coefficients, confint(ltest_afraid_full)))[2,]
names(fx.ltest_afraid_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_afraid_full$cond <- c("South Asian Treatment")
fx.ltest_afraid_full <-fx.ltest_afraid_full %>% 
  mutate(type="Afraid", group="Full Sample") 
fx.ltest_afraid_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_afraid_native<-lm(afraid~EthTreatment+ EconTreatment + female + education + 
                                 income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_afraid_native <- as.data.frame(cbind(ltest_afraid_native$coefficients, confint(ltest_afraid_native)))[2,]
names(fx.ltest_afraid_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_afraid_native$cond <- c("South Asian Treatment")
fx.ltest_afraid_native <-fx.ltest_afraid_native %>% 
  mutate(type="Afraid", group="Native Born") 
fx.ltest_afraid_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_afraid_foreign<-lm(afraid~EthTreatment+ EconTreatment + female + education + 
                                  income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_afraid_foreign <- as.data.frame(cbind(ltest_afraid_foreign$coefficients, confint(ltest_afraid_foreign)))[2,]
names(fx.ltest_afraid_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_afraid_foreign$cond <- c("South Asian Treatment")
fx.ltest_afraid_foreign <-fx.ltest_afraid_foreign %>% 
  mutate(type="Afraid", group="Foreign Born") 
fx.ltest_afraid_foreign

##Put together ltest ATES for plot
print(pred_asian_afraid_ltest<- rbind(fx.ltest_afraid_full, fx.ltest_afraid_native, fx.ltest_afraid_foreign))

```


#Asian Emotions: Angry
```{r South Asian:Angry ATE,  include=FALSE}
# Full sample (OLS)
summary(angry_full<- lm(angry~treatment, asian_data))
#Extract ATES with 95% CIs
fx.angry_full <- as.data.frame(cbind(angry_full$coefficients, confint(angry_full))[2:3,])
names(fx.angry_full) <- c("ate", "ci_l", "ci_u")
fx.angry_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.angry_full$cond <- factor(fx.angry_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.angry_full <-fx.angry_full %>% 
  mutate(type="Angry", group="Full Sample") 
fx.angry_full

# Subset to those who passed manipulation check
summary(angry_mcheck<- lm(angry~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(angry_native<- lm(angry~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.angry_native<- as.data.frame(cbind(angry_native$coefficients, confint(angry_native))[2:3,])
names(fx.angry_native) <- c("ate", "ci_l", "ci_u")
fx.angry_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.angry_native$cond <- factor(fx.angry_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.angry_native <-fx.angry_native %>% 
  mutate(type="Angry", group="Native Born") 
fx.angry_native

#Native Born with controls 
summary(angry_native_controls<- lm(angry~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(angry_native_controls_mcheck<- lm(angry~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(angry_foreign<- lm(angry~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.angry_foreign<- as.data.frame(cbind(angry_foreign$coefficients, confint(angry_foreign))[2:3,])
names(fx.angry_foreign) <- c("ate", "ci_l", "ci_u")
fx.angry_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.angry_foreign$cond <- factor(fx.angry_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.angry_foreign <-fx.angry_foreign %>% 
  mutate(type="Angry", group="Foreign Born") 
fx.angry_foreign

#Foreign Born with controls 
summary(angry_foreign_controls<- lm(angry~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(angry_foreign_controls_mcheck<- lm(angry~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))

#South Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(angry_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_angry_full<-lm(angry~EthTreatment+ EconTreatment, asian_data))
fx.ltest_angry_full <- as.data.frame(cbind(ltest_angry_full$coefficients, confint(ltest_angry_full)))[2,]
names(fx.ltest_angry_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_angry_full$cond <- c("South Asian Treatment")
fx.ltest_angry_full <-fx.ltest_angry_full %>% 
  mutate(type="Angry", group="Full Sample") 
fx.ltest_angry_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_angry_native<-lm(angry~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_angry_native <- as.data.frame(cbind(ltest_angry_native$coefficients, confint(ltest_angry_native)))[2,]
names(fx.ltest_angry_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_angry_native$cond <- c("South Asian Treatment")
fx.ltest_angry_native <-fx.ltest_angry_native %>% 
  mutate(type="Angry", group="Native Born") 
fx.ltest_angry_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_angry_foreign<-lm(angry~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_angry_foreign <- as.data.frame(cbind(ltest_angry_foreign$coefficients, confint(ltest_angry_foreign)))[2,]
names(fx.ltest_angry_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_angry_foreign$cond <- c("South Asian Treatment")
fx.ltest_angry_foreign <-fx.ltest_angry_foreign %>% 
  mutate(type="Angry", group="Foreign Born") 
fx.ltest_angry_foreign

##Put together ltest ATES for plot
print(pred_asian_angry_ltest<- rbind(fx.ltest_angry_full, fx.ltest_angry_native, fx.ltest_angry_foreign))

```


#Asian Emotions: Enthus
```{r South Asian:Enthus ATE,  include=FALSE}
# Full sample (OLS)
summary(enthus_full<- lm(enthus~treatment, asian_data))
#Extract ATES with 95% CIs
fx.enthus_full <- as.data.frame(cbind(enthus_full$coefficients, confint(enthus_full))[2:3,])
names(fx.enthus_full) <- c("ate", "ci_l", "ci_u")
fx.enthus_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.enthus_full$cond <- factor(fx.enthus_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.enthus_full <-fx.enthus_full %>% 
  mutate(type="Enthusiastic", group="Full Sample") 
fx.enthus_full

# Subset to those who passed manipulation check
summary(enthus_mcheck<- lm(enthus~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(enthus_native<- lm(enthus~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.enthus_native<- as.data.frame(cbind(enthus_native$coefficients, confint(enthus_native))[2:3,])
names(fx.enthus_native) <- c("ate", "ci_l", "ci_u")
fx.enthus_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.enthus_native$cond <- factor(fx.enthus_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.enthus_native <-fx.enthus_native %>% 
  mutate(type="Enthusiastic", group="Native Born") 
fx.enthus_native

#Native Born with controls 
summary(enthus_native_controls<- lm(enthus~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(enthus_native_controls_mcheck<- lm(enthus~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(enthus_foreign<- lm(enthus~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.enthus_foreign<- as.data.frame(cbind(enthus_foreign$coefficients, confint(enthus_foreign))[2:3,])
names(fx.enthus_foreign) <- c("ate", "ci_l", "ci_u")
fx.enthus_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.enthus_foreign$cond <- factor(fx.enthus_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.enthus_foreign <-fx.enthus_foreign %>% 
  mutate(type="Enthusiastic", group="Foreign Born") 
fx.enthus_foreign

#Foreign Born with controls 
summary(enthus_foreign_controls<- lm(enthus~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(enthus_foreign_controls_mcheck<- lm(enthus~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))


#South Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(enthus_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_enthus_full<-lm(enthus~EthTreatment+ EconTreatment, asian_data))
fx.ltest_enthus_full <- as.data.frame(cbind(ltest_enthus_full$coefficients, confint(ltest_enthus_full)))[2,]
names(fx.ltest_enthus_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_enthus_full$cond <- c("South Asian Treatment")
fx.ltest_enthus_full <-fx.ltest_enthus_full %>% 
  mutate(type="Enthus", group="Full Sample") 
fx.ltest_enthus_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_enthus_native<-lm(enthus~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_enthus_native <- as.data.frame(cbind(ltest_enthus_native$coefficients, confint(ltest_enthus_native)))[2,]
names(fx.ltest_enthus_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_enthus_native$cond <- c("South Asian Treatment")
fx.ltest_enthus_native <-fx.ltest_enthus_native %>% 
  mutate(type="Enthus", group="Native Born") 
fx.ltest_enthus_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_enthus_foreign<-lm(enthus~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_enthus_foreign <- as.data.frame(cbind(ltest_enthus_foreign$coefficients, confint(ltest_enthus_foreign)))[2,]
names(fx.ltest_enthus_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_enthus_foreign$cond <- c("South Asian Treatment")
fx.ltest_enthus_foreign <-fx.ltest_enthus_foreign %>% 
  mutate(type="Enthus", group="Foreign Born") 
fx.ltest_enthus_foreign

##Put together ltest ATES for plot
print(pred_asian_enthus_ltest<- rbind(fx.ltest_enthus_full, fx.ltest_enthus_native, fx.ltest_enthus_foreign))


```


#Asian Emotions: Hopeful
```{r South Asian:Hopeful ATE,  include=FALSE}
# Full sample (OLS)
summary(hopeful_full<- lm(hopeful~treatment, asian_data))
#Extract ATES with 95% CIs
fx.hopeful_full <- as.data.frame(cbind(hopeful_full$coefficients, confint(hopeful_full))[2:3,])
names(fx.hopeful_full) <- c("ate", "ci_l", "ci_u")
fx.hopeful_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.hopeful_full$cond <- factor(fx.hopeful_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.hopeful_full <-fx.hopeful_full %>% 
  mutate(type="Hopeful", group="Full Sample") 
fx.hopeful_full

# Subset to those who passed manipulation check
summary(hopeful_mcheck<- lm(hopeful~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(hopeful_native<- lm(hopeful~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.hopeful_native<- as.data.frame(cbind(hopeful_native$coefficients, confint(hopeful_native))[2:3,])
names(fx.hopeful_native) <- c("ate", "ci_l", "ci_u")
fx.hopeful_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.hopeful_native$cond <- factor(fx.hopeful_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.hopeful_native <-fx.hopeful_native %>% 
  mutate(type="Hopeful", group="Native Born") 
fx.hopeful_native

#Native Born with controls 
summary(hopeful_native_controls<- lm(hopeful~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(hopeful_native_controls_mcheck<- lm(hopeful~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(hopeful_foreign<- lm(hopeful~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.hopeful_foreign<- as.data.frame(cbind(hopeful_foreign$coefficients, confint(hopeful_foreign))[2:3,])
names(fx.hopeful_foreign) <- c("ate", "ci_l", "ci_u")
fx.hopeful_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.hopeful_foreign$cond <- factor(fx.hopeful_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.hopeful_foreign <-fx.hopeful_foreign %>% 
  mutate(type="Hopeful", group="Foreign Born") 
fx.hopeful_foreign

#Foreign Born with controls 
summary(hopeful_foreign_controls<- lm(hopeful~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(hopeful_foreign_controls_mcheck<- lm(hopeful~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))


#Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(hopeful_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_hopeful_full<-lm(hopeful~EthTreatment+ EconTreatment, asian_data))
fx.ltest_hopeful_full <- as.data.frame(cbind(ltest_hopeful_full$coefficients, confint(ltest_hopeful_full)))[2,]
names(fx.ltest_hopeful_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_hopeful_full$cond <- c("South Asian Treatment")
fx.ltest_hopeful_full <-fx.ltest_hopeful_full %>% 
  mutate(type="Hopeful", group="Full Sample") 
fx.ltest_hopeful_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_hopeful_native<-lm(hopeful~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_hopeful_native <- as.data.frame(cbind(ltest_hopeful_native$coefficients, confint(ltest_hopeful_native)))[2,]
names(fx.ltest_hopeful_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_hopeful_native$cond <- c("South Asian Treatment")
fx.ltest_hopeful_native <-fx.ltest_hopeful_native %>% 
  mutate(type="Hopeful", group="Native Born") 
fx.ltest_hopeful_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_hopeful_foreign<-lm(hopeful~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_hopeful_foreign <- as.data.frame(cbind(ltest_hopeful_foreign$coefficients, confint(ltest_hopeful_foreign)))[2,]
names(fx.ltest_hopeful_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_hopeful_foreign$cond <- c("South Asian Treatment")
fx.ltest_hopeful_foreign <-fx.ltest_hopeful_foreign %>% 
  mutate(type="Hopeful", group="Foreign Born") 
fx.ltest_hopeful_foreign

##Put together ltest ATES for plot
print(pred_asian_hopeful_ltest<- rbind(fx.ltest_hopeful_full, fx.ltest_hopeful_native, fx.ltest_hopeful_foreign))

```


#B.2 Table 8: Emotions ATEs (Full Asian Sample)
```{r South Asian:Sad Table Full, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
modellabels<-c("South Asian Treatment", "Immigrant Treatment")
stargazer(sad_full, angry_full, afraid_full, enthus_full, hopeful_full,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Emotion ATEs (Full Sample)",       
          label = "asian_emotion_full", 
          column.labels = c("Sad", "Angry", "Afraid", "Enthusiastic", "Hopeful"))

```


#C.2 Table 19: Emotion ATEs (Asian Sample + Manipulation Check)
```{r South Asian:Sad Table Full + Mcheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(sad_mcheck, angry_mcheck, afraid_mcheck, enthus_mcheck, hopeful_mcheck)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("South Asian Treatment", "Immigrant Treatment")
stargazer(m1, m2, m3, m4, m5,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Emotion ATEs (Full Sample + Passed Mcheck)",   
          label = "asian_emotion_full_mcheck", 
          column.labels = c("Sad", "Angry", "Afraid", "Enthusiastic", "Hopeful"))
```


#B.2 Table 9: Emotion ATEs (Native Born Asians)
```{r South Asian:Sad Table Native Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(sad_native, sad_native_controls, angry_native, angry_native_controls, afraid_native, afraid_native_controls, enthus_native, enthus_native_controls, hopeful_native, hopeful_native_controls)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("South Asian Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Indian", "English L.", "Pol. Interest" )
stargazer( m1, m2, m3, m4, m5, m6, m7, m8, m9, m10,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Emotion ATEs (Native Born Only)",   
          label = "asian_emotion_native", 
          column.labels = c("Sad", "Sad", "Angry", "Angry", "Afraid", "Afraid", "Enthus", "Enthus", "Hopeful", "Hopeful"))
```


#B.2 Table 10: Emotion ATEs (Foreign Born Asians)
```{r South Asian:Sad Table Foreign Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(sad_foreign, sad_foreign_controls, angry_foreign, angry_foreign_controls, afraid_foreign, afraid_foreign_controls,enthus_foreign, enthus_foreign_controls, hopeful_foreign, hopeful_foreign_controls)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}


modellabels<-c("South Asian Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Indian", "English L.", "Pol. Interest" )
stargazer( m1, m2, m3, m4, m5, m6, m7, m8, m9, m10,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Emotion ATEs (Foreign Born Only)",   
          label = "asian_emotion_foreign", 
          column.labels = c("Sad", "Sad", "Angry", "Angry", "Afraid", "Afraid", "Enthus", "Enthus", "Hopeful", "Hopeful"))
```


#C.2 Table 20: Asian Emotion ATEs (By Nativity + Manipulation Check)
```{r South Asian:Sad Table Nativity+MCheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(sad_native_controls_mcheck, sad_foreign_controls_mcheck, angry_native_controls_mcheck, angry_foreign_controls_mcheck, afraid_native_controls_mcheck, afraid_foreign_controls_mcheck, enthus_native_controls_mcheck, enthus_foreign_controls_mcheck, hopeful_native_controls_mcheck, hopeful_foreign_controls_mcheck)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("South Asian Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Indian", "English L.", "Pol. Interest" )
stargazer( m1, m2, m3, m4, m5, m6, m7, m8, m9, m10,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Emotion ATEs (By Natvivity + Passed Mcheck)",   
          label = "asian_emotion_nativity_mcheck", 
          column.labels = c("Sad", "Sad", "Angry", "Angry", "Afraid", "Afraid",  "Enthus", "Enthus", "Hopeful", "Hopeful"))
```


#Asian Emotion Plot Full Sample
```{r South Asian:Emotion Plot Full , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_asian_emotion_full<- rbind(fx.sad_full, fx.angry_full, fx.afraid_full, fx.enthus_full, fx.hopeful_full)

##This ensures the order of graphs are in the way in which we want them
pred_asian_emotion_full$type_f = factor(pred_asian_emotion_full$type, levels=c('Hopeful','Enthusiastic','Afraid', 'Angry', 'Sad'))

s1<-ggplot(pred_asian_emotion_full, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	#geom_errorbar(width=.12, alpha=1) +
	#geom_point(size=3, shape=21) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("South Asian", "Immigrant")) +
  scale_shape(labels = c("South Asian", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.4,.4), breaks=c(-.4, -.3, -.2, -.1, 0, .1, .2, .3, .4)) +
	ylab("Diff. in Emotion (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~group) +
  theme(legend.position = "bottom")

  ggsave("asian_emotion_full.png", plot = s1,
         width = 8, height = 5)
```


#Figure 4: Emotion ATEs, South Asian Sample by Nativity
```{r South Asian:Emotion Plot Nativity , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_asian_emotion_nativity<- rbind(fx.sad_native,fx.sad_foreign,fx.angry_native,fx.angry_foreign, fx.afraid_native,fx.afraid_foreign,  fx.enthus_native,fx.enthus_foreign, fx.hopeful_native, fx.hopeful_foreign)

##This ensures the order of graphs are in the way in which we want them
pred_asian_emotion_nativity$type_f = factor(pred_asian_emotion_nativity$type, levels=c('Hopeful', 'Enthusiastic', 'Angry', 'Afraid', 'Sad'))

s1<-ggplot(pred_asian_emotion_nativity, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	#geom_errorbar(width=.12, alpha=1) +
	#geom_point(size=3, shape=21) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("South Asian", "Immigrant")) +
  scale_shape(labels = c("South Asian", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.4,.45), breaks=c( -.4, -.3, -.2, -.1, 0, .1, .2, .3, .4)) +
	ylab("Diff. in Emotion (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~factor(group, levels=c("Native Born", "Foreign Born"))) +
  theme(legend.position = "bottom")

  ggsave("asian_emotion_nativity.png", plot = s1,
         width = 8, height = 5)
```




#Asian Trait: Cares
```{r South Asian: Cares ATE,  include=FALSE}
# Full sample (OLS)
summary(cares_full<- lm(cares~treatment, asian_data))
#Extract ATES with 95% CIs
fx.cares_full <- as.data.frame(cbind(cares_full$coefficients, confint(cares_full))[2:3,])
names(fx.cares_full) <- c("ate", "ci_l", "ci_u")
fx.cares_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.cares_full$cond <- factor(fx.cares_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.cares_full <-fx.cares_full %>% 
  mutate(type="Cares", group="Full Sample") 
fx.cares_full

# Subset to those who passed manipulation check
summary(cares_mcheck<- lm(cares~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(cares_native<- lm(cares~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.cares_native<- as.data.frame(cbind(cares_native$coefficients, confint(cares_native))[2:3,])
names(fx.cares_native) <- c("ate", "ci_l", "ci_u")
fx.cares_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.cares_native$cond <- factor(fx.cares_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.cares_native <-fx.cares_native %>% 
  mutate(type="Cares",group="Native Born") 
fx.cares_native

#Native Born with controls 
summary(cares_native_controls<- lm(cares~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(cares_native_controls_mcheck<- lm(cares~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(cares_foreign<- lm(cares~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.cares_foreign<- as.data.frame(cbind(cares_foreign$coefficients, confint(cares_foreign))[2:3,])
names(fx.cares_foreign) <- c("ate", "ci_l", "ci_u")
fx.cares_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.cares_foreign$cond <- factor(fx.cares_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.cares_foreign <-fx.cares_foreign %>% 
  mutate(type="Cares", group="Foreign Born") 
fx.cares_foreign

#Foreign Born with controls 
summary(cares_foreign_controls<- lm(cares~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(cares_foreign_controls_mcheck<- lm(cares~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))

#South Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(cares_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_cares_full<-lm(cares~EthTreatment+ EconTreatment, asian_data))
fx.ltest_cares_full <- as.data.frame(cbind(ltest_cares_full$coefficients, confint(ltest_cares_full)))[2,]
names(fx.ltest_cares_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_cares_full$cond <- c("South Asian Treatment")
fx.ltest_cares_full <-fx.ltest_cares_full %>% 
  mutate(type="Cares", group="Full Sample") 
fx.ltest_cares_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_cares_native<-lm(cares~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_cares_native <- as.data.frame(cbind(ltest_cares_native$coefficients, confint(ltest_cares_native)))[2,]
names(fx.ltest_cares_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_cares_native$cond <- c("South Asian Treatment")
fx.ltest_cares_native <-fx.ltest_cares_native %>% 
  mutate(type="Cares", group="Native Born") 
fx.ltest_cares_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_cares_foreign<-lm(cares~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_cares_foreign <- as.data.frame(cbind(ltest_cares_foreign$coefficients, confint(ltest_cares_foreign)))[2,]
names(fx.ltest_cares_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_cares_foreign$cond <- c("South Asian Treatment")
fx.ltest_cares_foreign <-fx.ltest_cares_foreign %>% 
  mutate(type="Cares", group="Foreign Born") 
fx.ltest_cares_foreign

##Put together ltest ATES for plot
print(pred_asian_cares_ltest<- rbind(fx.ltest_cares_full, fx.ltest_cares_native, fx.ltest_cares_foreign))

```

#Asian Trait: Honest
```{r South Asian: Honest ATE,  include=FALSE}
# Full sample (OLS)
summary(honest_full<- lm(honest~treatment, asian_data))
#Extract ATES with 95% CIs
fx.honest_full <- as.data.frame(cbind(honest_full$coefficients, confint(honest_full))[2:3,])
names(fx.honest_full) <- c("ate", "ci_l", "ci_u")
fx.honest_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.honest_full$cond <- factor(fx.honest_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.honest_full <-fx.honest_full %>% 
  mutate(type="Honest", group="Full Sample") 
fx.honest_full

# Subset to those who passed manipulation check
summary(honest_mcheck<- lm(honest~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(honest_native<- lm(honest~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.honest_native<- as.data.frame(cbind(honest_native$coefficients, confint(honest_native))[2:3,])
names(fx.honest_native) <- c("ate", "ci_l", "ci_u")
fx.honest_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.honest_native$cond <- factor(fx.honest_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.honest_native <-fx.honest_native %>% 
  mutate(type="Honest",group="Native Born") 
fx.honest_native

#Native Born with controls 
summary(honest_native_controls<- lm(honest~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(honest_native_controls_mcheck<- lm(honest~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(honest_foreign<- lm(honest~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.honest_foreign<- as.data.frame(cbind(honest_foreign$coefficients, confint(honest_foreign))[2:3,])
names(fx.honest_foreign) <- c("ate", "ci_l", "ci_u")
fx.honest_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.honest_foreign$cond <- factor(fx.honest_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.honest_foreign <-fx.honest_foreign %>% 
  mutate(type="Honest", group="Foreign Born") 
fx.honest_foreign

#Foreign Born with controls 
summary(honest_foreign_controls<- lm(honest~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(honest_foreign_controls_mcheck<- lm(honest~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))



#Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(honest_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_honest_full<-lm(honest~EthTreatment+ EconTreatment, asian_data))
fx.ltest_honest_full <- as.data.frame(cbind(ltest_honest_full$coefficients, confint(ltest_honest_full)))[2,]
names(fx.ltest_honest_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_honest_full$cond <- c("South Asian Treatment")
fx.ltest_honest_full <-fx.ltest_honest_full %>% 
  mutate(type="Honest", group="Full Sample") 
fx.ltest_honest_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_honest_native<-lm(honest~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_honest_native <- as.data.frame(cbind(ltest_honest_native$coefficients, confint(ltest_honest_native)))[2,]
names(fx.ltest_honest_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_honest_native$cond <- c("South Asian Treatment")
fx.ltest_honest_native <-fx.ltest_honest_native %>% 
  mutate(type="Honest", group="Native Born") 
fx.ltest_honest_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_honest_foreign<-lm(honest~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_honest_foreign <- as.data.frame(cbind(ltest_honest_foreign$coefficients, confint(ltest_honest_foreign)))[2,]
names(fx.ltest_honest_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_honest_foreign$cond <- c("South Asian Treatment")
fx.ltest_honest_foreign <-fx.ltest_honest_foreign %>% 
  mutate(type="Honest", group="Foreign Born") 
fx.ltest_honest_foreign

##Put together ltest ATES for plot
print(pred_asian_honest_ltest<- rbind(fx.ltest_honest_full, fx.ltest_honest_native, fx.ltest_honest_foreign))

```


#Asian Trait: Hardworking
```{r South Asian: Hardworking ATE,  include=FALSE}
# Full sample (OLS)
summary(hardworking_full<- lm(hardworking~treatment, asian_data))
#Extract ATES with 95% CIs
fx.hardworking_full <- as.data.frame(cbind(hardworking_full$coefficients, confint(hardworking_full))[2:3,])
names(fx.hardworking_full) <- c("ate", "ci_l", "ci_u")
fx.hardworking_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.hardworking_full$cond <- factor(fx.hardworking_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.hardworking_full <-fx.hardworking_full %>% 
  mutate(type="Hardworking", group="Full Sample") 
fx.hardworking_full

# Subset to those who passed manipulation check
summary(hardworking_mcheck<- lm(hardworking~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(hardworking_native<- lm(hardworking~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.hardworking_native<- as.data.frame(cbind(hardworking_native$coefficients, confint(hardworking_native))[2:3,])
names(fx.hardworking_native) <- c("ate", "ci_l", "ci_u")
fx.hardworking_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.hardworking_native$cond <- factor(fx.hardworking_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.hardworking_native <-fx.hardworking_native %>% 
  mutate(type="Hardworking",group="Native Born") 
fx.hardworking_native

#Native Born with controls 
summary(hardworking_native_controls<- lm(hardworking~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(hardworking_native_controls_mcheck<- lm(hardworking~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(hardworking_foreign<- lm(hardworking~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.hardworking_foreign<- as.data.frame(cbind(hardworking_foreign$coefficients, confint(hardworking_foreign))[2:3,])
names(fx.hardworking_foreign) <- c("ate", "ci_l", "ci_u")
fx.hardworking_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.hardworking_foreign$cond <- factor(fx.hardworking_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.hardworking_foreign <-fx.hardworking_foreign %>% 
  mutate(type="Hardworking", group="Foreign Born") 
fx.hardworking_foreign

#Foreign Born with controls 
summary(hardworking_foreign_controls<- lm(hardworking~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(hardworking_foreign_controls_mcheck<- lm(hardworking~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))


#South Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(hardworking_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_hardworking_full<-lm(hardworking~EthTreatment+ EconTreatment, asian_data))
fx.ltest_hardworking_full <- as.data.frame(cbind(ltest_hardworking_full$coefficients, confint(ltest_hardworking_full)))[2,]
names(fx.ltest_hardworking_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_hardworking_full$cond <- c("South Asian Treatment")
fx.ltest_hardworking_full <-fx.ltest_hardworking_full %>% 
  mutate(type="Hardworking", group="Full Sample") 
fx.ltest_hardworking_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_hardworking_native<-lm(hardworking~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_hardworking_native <- as.data.frame(cbind(ltest_hardworking_native$coefficients, confint(ltest_hardworking_native)))[2,]
names(fx.ltest_hardworking_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_hardworking_native$cond <- c("South Asian Treatment")
fx.ltest_hardworking_native <-fx.ltest_hardworking_native %>% 
  mutate(type="Hardworking", group="Native Born") 
fx.ltest_hardworking_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_hardworking_foreign<-lm(hardworking~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_hardworking_foreign <- as.data.frame(cbind(ltest_hardworking_foreign$coefficients, confint(ltest_hardworking_foreign)))[2,]
names(fx.ltest_hardworking_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_hardworking_foreign$cond <- c("South Asian Treatment")
fx.ltest_hardworking_foreign <-fx.ltest_hardworking_foreign %>% 
  mutate(type="Hardworking", group="Foreign Born") 
fx.ltest_hardworking_foreign

##Put together ltest ATES for plot
print(pred_asian_hardworking_ltest<- rbind(fx.ltest_hardworking_full, fx.ltest_hardworking_native, fx.ltest_hardworking_foreign))

```


#Asian Vote Stevens
```{r South Asian: VoteStevens ATE,  include=FALSE}
# Full sample (OLS)
summary(voteStevens_full<- lm(voteStevens~treatment, asian_data))
#Extract ATES with 95% CIs
fx.voteStevens_full <- as.data.frame(cbind(voteStevens_full$coefficients, confint(voteStevens_full))[2:3,])
names(fx.voteStevens_full) <- c("ate", "ci_l", "ci_u")
fx.voteStevens_full$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.voteStevens_full$cond <- factor(fx.voteStevens_full$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.voteStevens_full <-fx.voteStevens_full %>% 
  mutate(type="VoteStevens", group="Full Sample") 
fx.voteStevens_full

# Subset to those who passed manipulation check
summary(voteStevens_mcheck<- lm(voteStevens~treatment, asian_data,subset=asian_data$manipulation_topic==1))

# Native Born
summary(voteStevens_native<- lm(voteStevens~treatment, asian_data,subset=asian_data$native_born == 1))
#Extract ATES with 95% CIs
fx.voteStevens_native<- as.data.frame(cbind(voteStevens_native$coefficients, confint(voteStevens_native))[2:3,])
names(fx.voteStevens_native) <- c("ate", "ci_l", "ci_u")
fx.voteStevens_native$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.voteStevens_native$cond <- factor(fx.voteStevens_native$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.voteStevens_native <-fx.voteStevens_native %>% 
  mutate(type="VoteStevens",group="Native Born") 
fx.voteStevens_native

#Native Born with controls 
summary(voteStevens_native_controls<- lm(voteStevens~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$native_born == 1))

#Native Born with controls + Mcheck
summary(voteStevens_native_controls_mcheck<- lm(voteStevens~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset=asian_data$manipulation_topic==1 & asian_data$native_born == 1))

# Foreign born
summary(voteStevens_foreign<- lm(voteStevens~treatment, asian_data,subset= asian_data$native_born == 0))
#Extract ATES with 95% CIs
fx.voteStevens_foreign<- as.data.frame(cbind(voteStevens_foreign$coefficients, confint(voteStevens_foreign))[2:3,])
names(fx.voteStevens_foreign) <- c("ate", "ci_l", "ci_u")
fx.voteStevens_foreign$cond <- c("South Asian Treatment", "Immigrant Treatment")
fx.voteStevens_foreign$cond <- factor(fx.voteStevens_foreign$cond, levels=c("South Asian Treatment", "Immigrant Treatment"))
fx.voteStevens_foreign <-fx.voteStevens_foreign %>% 
  mutate(type="VoteStevens", group="Foreign Born") 
fx.voteStevens_foreign

#Foreign Born with controls 
summary(voteStevens_foreign_controls<- lm(voteStevens~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$native_born == 0))

#Foreign Born with controls + Mcheck
summary(voteStevens_foreign_controls_mcheck<- lm(voteStevens~treatment+ female+education+income+age+indian+ english_lang+interest, asian_data,subset= asian_data$manipulation_topic==1 & asian_data$native_born == 0))



#South Asian v. Immigrant Treatment (Full Sample)
linearHypothesis(voteStevens_full, c("treatmentAsian =treatmentImmigrant"))
summary(ltest_voteStevens_full<-lm(voteStevens~EthTreatment+ EconTreatment, asian_data))
fx.ltest_voteStevens_full <- as.data.frame(cbind(ltest_voteStevens_full$coefficients, confint(ltest_voteStevens_full)))[2,]
names(fx.ltest_voteStevens_full) <- c("ate", "ci_l", "ci_u")
fx.ltest_voteStevens_full$cond <- c("South Asian Treatment")
fx.ltest_voteStevens_full <-fx.ltest_voteStevens_full %>% 
  mutate(type="VoteStevens", group="Full Sample") 
fx.ltest_voteStevens_full

#South Asian v. Immigrant Treatment (Native)
summary(ltest_voteStevens_native<-lm(voteStevens~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 1))
fx.ltest_voteStevens_native <- as.data.frame(cbind(ltest_voteStevens_native$coefficients, confint(ltest_voteStevens_native)))[2,]
names(fx.ltest_voteStevens_native) <- c("ate", "ci_l", "ci_u")
fx.ltest_voteStevens_native$cond <- c("South Asian Treatment")
fx.ltest_voteStevens_native <-fx.ltest_voteStevens_native %>% 
  mutate(type="VoteStevens", group="Native Born") 
fx.ltest_voteStevens_native

#South Asian v. Immigrant Treatment (Foreign)
summary(ltest_voteStevens_foreign<-lm(voteStevens~EthTreatment+ EconTreatment + female + education + 
    income + age + indian + english_lang + interest, asian_data, subset= asian_data$native_born == 0))
fx.ltest_voteStevens_foreign <- as.data.frame(cbind(ltest_voteStevens_foreign$coefficients, confint(ltest_voteStevens_foreign)))[2,]
names(fx.ltest_voteStevens_foreign) <- c("ate", "ci_l", "ci_u")
fx.ltest_voteStevens_foreign$cond <- c("South Asian Treatment")
fx.ltest_voteStevens_foreign <-fx.ltest_voteStevens_foreign %>% 
  mutate(type="VoteStevens", group="Foreign Born") 
fx.ltest_voteStevens_foreign

##Put together ltest ATES for plot
pred_asian_voteStevens_ltest<- rbind(fx.ltest_voteStevens_full, fx.ltest_voteStevens_native, fx.ltest_voteStevens_foreign)

```


#B.4 Table 14: Candidate Evaluation ATEs (Full Asian Sample)
```{r South Asian: Trait Table Full Sample, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
modellabels<-c("South Asian Treatment", "Immigrant Treatment")
stargazer(cares_full, honest_full, hardworking_full, voteStevens_full,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Candidate Trait and Vote Choice ATEs (Full Sample + Passed Mcheck)",   
          label = "asian_trait_full_mcheck", 
          column.labels = c("Cares", "Honest", "Hardworking", "Vote Stevens"))
```


#C.4 Table 23: Candidate Evaluation ATEs (Asian Sample + Manipulation Check)
```{r South Asian: Trait Table Full + Mcheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
modellabels<-c("South Asian Treatment", "Immigrant Treatment")
stargazer(cares_mcheck, honest_mcheck, hardworking_mcheck, voteStevens_mcheck,
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asian Candidate Trait and Vote Choice ATEs (Full Sample + Passed Mcheck)",   
          label = "asian_trait_full_mcheck", 
          column.labels = c("Cares", "Honest", "Hardworking", "Vote Stevens"))
```


#C.4 Table 24: Asian Candidate Evaluation ATEs (By Nativity + Manipulation Check)
```{r South Asia: Trait Table Nativity+MCheck, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(cares_native_controls_mcheck, cares_foreign_controls_mcheck, honest_native_controls_mcheck, honest_foreign_controls_mcheck, hardworking_native_controls_mcheck, hardworking_foreign_controls_mcheck, voteStevens_native_controls_mcheck, voteStevens_foreign_controls_mcheck)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}


modellabels<-c("South Asia Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Indian", "English L.", "Pol. Interest" )
stargazer(m1, m2, m3, m4, m5, m6, m7, m8, 
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asia Candidate Trait and Vote Choice ATEs (By Natvivity + Passed Mcheck)",   
          label = "asian_trait_nativity_mcheck", 
          column.labels = c("Cares","Cares", "Honest","Honest", "Hardworking","Hardworking", 
                            "Vote","Vote"))
```


#B.4 Table 15: Candidate Evaluation ATEs (Native Born Asians)
```{r South Asian:Trait Table Native Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(cares_native, cares_native_controls, honest_native, honest_native_controls,hardworking_native, hardworking_native_controls, voteStevens_native, voteStevens_native_controls)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}


modellabels<-c("South Asia Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Indian", "English L.", "Pol. Interest" )
stargazer(m1, m2, m3, m4, m5, m6, m7, m8, 
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asia Candidate Trait and Vote Choice ATEs (Native Born Only)",   
          label = "asian_trait_native", 
          column.labels = c("Cares","Cares", "Honest","Honest", "Hardworking","Hardworking", 
                            "Vote","Vote"))
```

#B.4 Table 16: Candidate Evaluation ATEs (Foreign Born Asians)
```{r South Asia: Trait Table Freign Born, echo=FALSE, message=FALSE, warning=FALSE, results='asis'}
old_models <- list(cares_foreign, cares_foreign_controls, honest_foreign, honest_foreign_controls,hardworking_foreign, hardworking_foreign_controls, voteStevens_foreign, voteStevens_foreign_controls)

for (i in seq_along(old_models)) {
  assign(paste0("m", i), old_models[[i]], envir = .GlobalEnv)
}

modellabels<-c("South Asia Treat.", "Immigrant Treat.", "Female", "Education", "Income", "Age", "Indian", "English L.", "Pol. Interest" )
stargazer(m1, m2, m3, m4, m5, m6, m7, m8, 
  style="ajps", covariate.labels = modellabels, out.header=T, font.size="scriptsize", omit.stat = c("f", "ser"),
          model.numbers = TRUE, 
          title = "South Asia Candidate Trait and Vote Choice ATEs (Foreign Born Only)",   
          label = "asian_trait_foreign", 
          column.labels = c("Cares","Cares", "Honest","Honest", "Hardworking","Hardworking", 
                            "Vote","Vote"))
```


#South Asia Trait Plot Full Sample
```{r South Asia:Trait Plot Full , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_asian_trait_full<- rbind(fx.cares_full, fx.honest_full, fx.hardworking_full, fx.voteStevens_full)

##This ensures the order of graphs are in the way in which we want them
pred_asian_trait_full$type_f = factor(pred_asian_trait_full$type, levels=c('VoteStevens','Hardworking','Honest', 'Cares'))

s1<-ggplot(pred_asian_trait_full, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("South Asia", "Immigrant")) +
  scale_shape(labels = c("South Asia", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.4,.1), breaks=c(-.4, -.3, -.2, -.1, 0, .1)) +
	ylab("Diff. in Trait/Vote (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~group) +
  theme(legend.position = "bottom")

  ggsave("asian_trait_full.png", plot = s1,
         width = 8, height = 5)
```


#Figure 5: Candidate Evaluation ATEs, South Asian Sample by Nativity
```{r South Asia:Trait Plot Nativity , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot
pred_asian_trait_nativity<- rbind(fx.cares_native,fx.cares_foreign,fx.honest_native,fx.honest_foreign,  fx.hardworking_native,fx.hardworking_foreign, fx.voteStevens_native, fx.voteStevens_foreign)

##This ensures the order of graphs are in the way in which we want them
pred_asian_trait_nativity$type_f = factor(pred_asian_trait_nativity$type, levels=c('VoteStevens','Hardworking','Honest', 'Cares'))

s1<-ggplot(pred_asian_trait_nativity, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=cond, color=cond))+
	geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
	geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("South Asian", "Immigrant")) +
  scale_shape(labels = c("South Asian", "Immigrant"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.45,.1), breaks=c(-.4, -.3, -.2, -.1, 0, .1)) +
	ylab("Diff. in Trait/Vote (Compared to Baseline Econ Condition)") + xlab("") +
  labs(color = "Treatment", shape = "Treatment") + 
  coord_flip() + 
  facet_wrap(~factor(group, levels=c("Native Born", "Foreign Born"))) +
  theme(legend.position = "bottom")

  ggsave("asian_trait_nativity.png", plot = s1,
         width = 8, height = 5)

```


#Figure 6: Difference between Panethnic and Immigrant Treatments, South Asian Sample by Nativity
```{r South Asia:Diff Plot , echo=FALSE, message=FALSE, warning=FALSE, fig.height=6, fig.show='asis', fig.width=8}

##Put together ATES for plot

pred_asian_sad_ltest<- rbind(fx.ltest_sad_native, fx.ltest_sad_foreign)

pred_asian_angry_ltest<- rbind(fx.ltest_angry_native, fx.ltest_angry_foreign)

pred_asian_afraid_ltest<- rbind(fx.ltest_afraid_native, fx.ltest_afraid_foreign)

pred_asian_enthus_ltest<- rbind(fx.ltest_enthus_native, fx.ltest_enthus_foreign)


pred_asian_hopeful_ltest<- rbind(fx.ltest_hopeful_native, fx.ltest_hopeful_foreign)


pred_asian_cares_ltest<- rbind(fx.ltest_cares_native, fx.ltest_cares_foreign)

pred_asian_honest_ltest<- rbind(fx.ltest_honest_native, fx.ltest_honest_foreign)

pred_asian_hardworking_ltest<- rbind(fx.ltest_hardworking_native, fx.ltest_hardworking_foreign)

pred_asian_voteStevens_ltest<- rbind(fx.ltest_voteStevens_native, fx.ltest_voteStevens_foreign)


pred_asian_all_ltest<- rbind(pred_asian_sad_ltest,pred_asian_angry_ltest, pred_asian_afraid_ltest, pred_asian_enthus_ltest, pred_asian_hopeful_ltest,pred_asian_cares_ltest, pred_asian_honest_ltest,pred_asian_hardworking_ltest, pred_asian_voteStevens_ltest)

##This ensures the order of graphs are in the way in which we want them
pred_asian_all_ltest$type_f = factor(pred_asian_all_ltest$type, levels=c('VoteStevens','Hardworking','Honest', 'Cares', 'Hopeful', 'Enthus', 'Afraid', 'Angry', 'Sad'))

pred_asian_all_ltest$group <- factor(pred_asian_all_ltest$group, levels = c("Native Born", "Foreign Born"))


s1<-ggplot(pred_asian_all_ltest, aes(x=type_f, y=ate, ymin=ci_l, ymax=ci_u, shape=group, color=group))+
  geom_hline(yintercept=0, color="maroon", size=.5, linetype = 2) +
  geom_pointrange(size = .75, position = position_dodge(width = .5)) +
  scale_color_brewer(palette = "Set1", labels = c("Native Born", "Foreign Born")) +
  scale_shape(labels = c("Native Born", "Foreign Born"))+
  theme_bw(base_size=14)  +
  scale_y_continuous(limits=c(-.2,.2), breaks=c(-.2, -.1, 0, .1, .2)) +
  ylab("South Asian Treatment compared to Immigrant Treatment") + xlab("") +
  labs(color = "", shape = "") + 
  coord_flip() + 
  facet_wrap(~factor(group, levels=c("Native Born", "Foreign Born"))) +
  theme(legend.position = "bottom")

ggsave("asian_diff_by_nativity.png", plot = s1,
       width = 8, height = 5)

```


#Figure A1 Produced in Stata (code below)
```{r Figure A1, include=FALSE}

#use "Latino_data_Stata.dta", clear

#// create immIDPG variable
#gen immIDPG= imm_id1 + imm_id2 + imm_id3 + imm_id4
#replace  immIDPG=(immIDPG-4)/16

#tab immIDPG

#reg immIDPG i.imm##treatment  
#margins,  at( imm=(0 1) treatment=(0 1 2)) 
#mplotoffset,  recast(scatter)  title("", bexpand nospan) ///
# ytitle("Immigrant Identity")   ylabel(.4(.1).7, grid glcolor(gs12))  ///
# xtitle("") xlabel(0 "Native Born" 1 "Immigrant", grid glcolor(gs12))   ///
# legend(position(6) col(3)) ///
#plot1opt(msymbol(triangle)) ///
#plot2opt(msymbol(circle)) ///
#plot3opt(msymbol(square)) ///
# xsize(5) ysize(5)

#graph save "Graph" "Immigrant Identity.gph", replace
#graph export "Immigrant Identity.png", as(png) name("Graph") replace

```
